﻿using Microsoft.Xna.Framework.Graphics;
using System;
using Microsoft.Xna.Framework;


using System.Threading;
using System.Collections.Generic;
using System.Runtime.InteropServices;

using FXnaEngine;


namespace FXnaGraphics.WPF
{

     
    /// <summary>
    /// 在这里提供引擎的封装
    /// </summary>
    public  class FXnaWPFCanvas:WPFCanvas
    {



        IGraphicsDeviceService graphics;


        FGame game;

        public FXnaWPFCanvas()
        {


            if (!(System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)))
            {





                this.graphics = new FGameDeviceManager(this);


                game = new FGame();



               
              
               
                //Content.RootDirectory = "Content";



            }



           




        }


        protected override void Initialize()
        {

            //在之前初始化引擎，在这里设备已经被创建

           

            this.game.InitEngine(this.graphics, this.Content, this.Services);



            base.Initialize();

        }

       



        protected override void Draw(GameTime gameTime)
        {
            //graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            this.game.Draw(gameTime);

            base.Draw(gameTime);

           


        }


        protected override void Update(GameTime gameTime)
        {

            this.game.Update(gameTime);


            base.Update(gameTime);

            


        }


        protected override void LoadContent()
        {
           

            this.game.LoadContent();

            base.LoadContent();

        }


        protected override void UnloadContent()
        {

            this.game.UnloadContent();

            base.UnloadContent();

          



        }





        #region 字段

        GraphicsDeviceService graphicsDeviceService;

        #endregion




    }
}
